package com.pavel.taskig.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Taskig implements EntryPoint {
	private VerticalPanel mainPanel = new VerticalPanel();
	private Button addTaskButton;

	/**
	 * Create a remote service proxy to talk to the server-side Greeting
	 * service.
	 */
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		addTaskButton = new Button("Add a Task");
		addTaskButton.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				addNewTask();
			}
		});
		mainPanel.add(addTaskButton);
		RootPanel.get("taski").add(mainPanel);
	}

	protected void addNewTask() {
		addTaskButton.setEnabled(false);
		AddTaskTable table = new AddTaskTable(addTaskButton);
		mainPanel.add(table);
	}
}
